package com.xinqi.modules.homework.homework.client;

import com.xinqi.common.base.constants.ServiceNameConstants;
import com.xinqi.common.base.response.R;
import com.xinqi.common.core.enums.StudentOperateGroup;
import com.xinqi.common.core.enums.StudentSwitchType;
import com.xinqi.modules.homework.homework.dto.req.CourseHomeworkStudentDetailDTO;
import com.xinqi.modules.homework.homework.dto.req.CourseHomeworkUpdateDTO;
import com.xinqi.modules.homework.homework.dto.rsp.CourseHomeworkResultDTO;
import com.xinqi.modules.homework.homework.factory.CourseHomeworkFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@FeignClient(contextId = "courseHomeworkClient", value = ServiceNameConstants.XQ_HOMEWORK, fallbackFactory = CourseHomeworkFallbackFactory.class)
public interface CourseHomeworkClient {

    /**
     * 更新作业定时发布状态
     *
     * @return boolean
     */
    @GetMapping("/inner/homework/timing")
    R<String> timingRun();

    /**
     * 更新作业轮数状态为进行中
     *
     * @return boolean
     */
    @GetMapping("/inner/homework/times/in-progress")
    R<String> timesInProgressRun();

    /**
     * 更新作业轮数状态为已结束
     *
     * @return boolean
     */
    @GetMapping("/inner/homework/times/closed")
    R<String> timesClosedRun();

    /**
     * 作业学生退组、进组
     *
     * @return
     */
    @PostMapping("/inner/homework/student-operate-group")
    R<String> studentOperateGroup(@RequestParam("classId") Long classId, @RequestParam("studentId") Long studentId, @RequestParam("groupId") Long groupId, @RequestParam("operateGroup") StudentOperateGroup operateGroup);


    /**
     * 学生加入班级-作业同步
     *
     * @return
     */
    @PostMapping("/inner/homework/student-join-class")
    R<Void> studentJoinClass(@RequestParam("classId") Long classId, @RequestParam("studentId") Long studentId);

    /**
     * 学生身份转换
     *
     * @return
     */
    @PostMapping("/inner/homework/student-identity-switch")
    R<Void> studentIdentitySwitch(@RequestParam("classId") Long classId, @RequestParam("studentId") Long studentId, @RequestParam("switchType") StudentSwitchType switchType);

    /**
     * 查询课程栏目作业-详情
     *
     * @Author dzy
     * @Date 10:10 2023/3/9 0009
     * @Return
     */
    @GetMapping("/inner/homework/{id}")
    R<CourseHomeworkResultDTO> findById(@PathVariable("id") Long id, CourseHomeworkStudentDetailDTO dto);

    /**
     * 修改课程栏目作业信息
     *
     * @Author dzy
     * @Date 10:10 2023/3/9 0009
     * @Return
     */
    @PutMapping("/inner/homework/{id}")
    R<String> update(@PathVariable("id") Long id, @Validated @RequestBody CourseHomeworkUpdateDTO dto);
}
